package fr;




import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.jasper.tagplugins.jstl.core.Redirect;




public class RootServlet extends HttpServlet {

	protected void doPost(HttpServletRequest request, HttpServletResponse resp)
			throws ServletException, IOException {	doGet(request, resp);

	}


	protected void doGet(HttpServletRequest request, HttpServletResponse resp)
			throws ServletException, IOException {



		ServletContext x = getServletContext();

		System.out.println(x.getAttribute("connection"));
		if (x.getAttribute("connection").equals("true" ))
			System.out.println("connexion ok");
		else
	    resp.sendRedirect("Error.jsp");
			

		resp.setContentType( "text/html" );

		PrintWriter out = resp.getWriter();



		out.print("<html>");
		out.println( "<head>" );
		out.println( "<title>Servlet</title>" );
		out.println( "</head>" );
		out.println( "<body>" );

		out.println( "<h1>Formulaire</h1>" );
		// affichage adresse ip
		out.println ("<h4>Adesses IP</h4>");
		out.println( request.getAttribute("monIp"));
		out.println("<br>");
		out.println( request.getAttribute("IP"));


		out.println("<form action=\"controle\" method=\"get\"><table border=\"0\">");		
		out.println("<tr>");
		out.println("<td>Login<td>");

		out.println("<input type=\"text\" name=\"login\" value =\" \" size= \"20\"</input>");
		out.println("<br>");
		out.println("<tr>");
		out.println("<td>Mot de passe<td>");
		out.println("<input type=\"text\" name=\"motdepasse\" value =\" \" size= \"20\"</input>");

		out.println("<br>");
		out.println("<tr>");
		out.println("<td><td>");
		out.println("<input type=\"submit\" value=\"valider\"</input>");
		out.println( "</body></html>" );

	}

}






















